using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
using WPFExcelReport.Helpers;
using WPFExcelReport.Controls;
namespace WPFExcelReport
{
    public partial class VEKADR
    {
        public void SetUpNewRow(ref DataRow dwReturn)
        {

            switch (app.company)
            {
                case "YGR":
                case "YCC":
                case "TST":
                default:
                    #region=========
                    dwReturn["EKAMANDANT"] = "00";
                    dwReturn["EKAAUFKRS"] = "14";
                    dwReturn["EKAAUFLFD"] = "000001";
                    dwReturn["EKAAUFPOS"] = "000";
                    dwReturn["EKABNAME1"] = "                                        ";
                    dwReturn["EKABNAME2"] = "                                        ";
                    dwReturn["EKABSTRASSE1"] = "                                        ";
                    dwReturn["EKABSTRASSE2"] = "                                        ";
                    dwReturn["EKABLKZ"] = "   ";
                    dwReturn["EKABPLZ"] = "            ";
                    dwReturn["EKABORT"] = "                                        ";
                    dwReturn["EKABPLZPF"] = "            ";
                    dwReturn["EKABPOSTF"] = "               ";
                    dwReturn["EKABBZ"] = "  ";
                    dwReturn["EKABBZBEZ"] = "             ";
                    dwReturn["EKABCOUNTY"] = "    ";
                    dwReturn["EKABCITY"] = "    ";
                    dwReturn["EKABANSPNA"] = "                                        ";
                    dwReturn["EKALNAME1"] = "                                        ";
                    dwReturn["EKALNAME2"] = "                                        ";
                    dwReturn["EKALSTRASSE1"] = "                                        ";
                    dwReturn["VKALSTRASSE2"] = "                                        ";
                    dwReturn["EKALLKZ"] = "   ";
                    dwReturn["EKALPLZ"] = "            ";
                    dwReturn["EKALORT"] = "                                        ";
                    dwReturn["EKALBZ"] = "  ";
                    dwReturn["EKALBZBEZ"] = "             ";
                    dwReturn["EKALCOUNTY"] = "    ";
                    dwReturn["EKALCITY"] = "    ";
                    dwReturn["EKAADRSL1"] = "SY      ";
                    dwReturn["EKALIEFNR1"] = "00000000";
                    dwReturn["EKAANZ1"] = "01";
                    dwReturn["EKAADRSLK11"] = "        ";
                    dwReturn["EKALIEFNRK11"] = "        ";
                    dwReturn["EKAANZK11"] = "00";
                    dwReturn["EKAADRSLK21"] = "        ";
                    dwReturn["EKALIEFNRK21"] = "        ";
                    dwReturn["EKAANZK21"] = "00";
                    dwReturn["EKAADRSL2"] = "        ";
                    dwReturn["EKALIEFNR2"] = "        ";
                    dwReturn["EKAANZ2"] = "00";
                    dwReturn["EKAADRSLK12"] = "        ";
                    dwReturn["EKALIEFNRK12"] = "        ";
                    dwReturn["EKAANZK12"] = "00";
                    dwReturn["EKAADRSLK22"] = "        ";
                    dwReturn["EKALIEFNRK22"] = "        ";
                    dwReturn["EKAANZK22"] = "00";
                    dwReturn["EKAADRSL3"] = "        ";
                    dwReturn["EKALIEFNR3"] = "        ";
                    dwReturn["EKAANZ3"] = "00";
                    dwReturn["EKAADRSLK13"] = "        ";
                    dwReturn["EKALIEFNRK13"] = "        ";
                    dwReturn["EKAANZK13"] = "00";
                    dwReturn["EKAADRSLK23"] = "        ";
                    dwReturn["EKALIEFNRK23"] = "        ";
                    dwReturn["EKAANZK23"] = "00";
                    dwReturn["EKAFREIBAD"] = "N";
                    dwReturn["EKAFREILAD"] = "N";
                    dwReturn["EKAERLKZ"] = " ";
                    dwReturn["EKAFILLER1"] = "                                                     ";
                    dwReturn["EKAAENZL"] = "1";
                    dwReturn["EKAAENB"] = "INTEXE  ";
                    dwReturn["EKAAEND"] = "20150930";
                    dwReturn["EKANEUB"] = "INTEXE  ";
                    dwReturn["EKANEUD"] = "20140920";


                    #endregion
                    break;
            }
        }
        public void InsertEKADR(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            or1 = OracleDB.CreateCommand();
            switch (ITXDBVERSION)
            {
                default:
                case "TST":
                case "YGR":
                    or1.CommandText = "INSERT INTO EKADR ( EKAMANDANT,EKAAUFKRS,EKAAUFLFD,EKAAUFPOS,EKABNAME1,EKABNAME2,EKABSTRASSE1,EKABSTRASSE2,EKABLKZ,EKABPLZ,EKABORT,EKABPLZPF,EKABPOSTF,EKABBZ,EKABBZBEZ,EKABCOUNTY,EKABCITY,EKABANSPNA,EKALNAME1,EKALNAME2,EKALSTRASSE1,VKALSTRASSE2,EKALLKZ,EKALPLZ,EKALORT,EKALBZ,EKALBZBEZ,EKALCOUNTY,EKALCITY,EKAADRSL1,EKALIEFNR1,EKAANZ1,EKAADRSLK11,EKALIEFNRK11,EKAANZK11,EKAADRSLK21,EKALIEFNRK21,EKAANZK21,EKAADRSL2,EKALIEFNR2,EKAANZ2,EKAADRSLK12,EKALIEFNRK12,EKAANZK12,EKAADRSLK22,EKALIEFNRK22,EKAANZK22,EKAADRSL3,EKALIEFNR3,EKAANZ3,EKAADRSLK13,EKALIEFNRK13,EKAANZK13,EKAADRSLK23,EKALIEFNRK23,EKAANZK23,EKAFREIBAD,EKAFREILAD,EKAERLKZ,EKAFILLER1,EKAAENZL,EKAAENB,EKAAEND,EKANEUB,EKANEUD)"
                   + " VALUES (:EKAMANDANT:,:EKAAUFKRS:,:EKAAUFLFD:,:EKAAUFPOS:,:EKABNAME1:,:EKABNAME2:,:EKABSTRASSE1:,:EKABSTRASSE2:,:EKABLKZ:,:EKABPLZ:,:EKABORT:,:EKABPLZPF:,:EKABPOSTF:,:EKABBZ:,:EKABBZBEZ:,:EKABCOUNTY:,:EKABCITY:,:EKABANSPNA:,:EKALNAME1:,:EKALNAME2:,:EKALSTRASSE1:,:VKALSTRASSE2:,:EKALLKZ:,:EKALPLZ:,:EKALORT:,:EKALBZ:,:EKALBZBEZ:,:EKALCOUNTY:,:EKALCITY:,:EKAADRSL1:,:EKALIEFNR1:,:EKAANZ1:,:EKAADRSLK11:,:EKALIEFNRK11:,:EKAANZK11:,:EKAADRSLK21:,:EKALIEFNRK21:,:EKAANZK21:,:EKAADRSL2:,:EKALIEFNR2:,:EKAANZ2:,:EKAADRSLK12:,:EKALIEFNRK12:,:EKAANZK12:,:EKAADRSLK22:,:EKALIEFNRK22:,:EKAANZK22:,:EKAADRSL3:,:EKALIEFNR3:,:EKAANZ3:,:EKAADRSLK13:,:EKALIEFNRK13:,:EKAANZK13:,:EKAADRSLK23:,:EKALIEFNRK23:,:EKAANZK23:,:EKAFREIBAD:,:EKAFREILAD:,:EKAERLKZ:,:EKAFILLER1:,:EKAAENZL:,:EKAAENB:,:EKAAEND:,:EKANEUB:,:EKANEUD:)";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
                    //VAFMANDANT VAFKOLL VAFART VAFFARBE VAFBEZ VAFFFARBE

            }

            Connect2Proxy(or1);
        }

        public DataSet QEKA01(DataRow dwData, int option = 1)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM EKADR "
                + " WHERE  EKAMANDANT=:EKAMANDANT: AND EKAAUFKRS=:EKAAUFKRS: AND EKAAUFLFD=:EKAAUFLFD: AND EKAAUFPOS=:EKAAUFPOS: ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public void DEKA01(DataRow dwData, int option = 1)
        {
            dwData["EKANEUB"] = app.Mandant;
            dwData["EKANEUD"] = date; 

            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "DELETE FROM EKADR  "
                        + " WHERE  EKAMANDANT=:EKAMANDANT: AND EKAAUFKRS=:EKAAUFKRS: AND EKAAUFLFD=:EKAAUFLFD: AND EKAAUFPOS=:EKAAUFPOS: ";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
                default:
                    break;
            }
            Connect2Proxy(or1);
        }

        public void UpdateEKADR(DataRow dwData, string ITXDBVERSION = "50.24", int option = 1)
        {
            if (option == 0)
            {
                switch (app.company)
                {
                    default:
                    case "TST":
                        option = 1;
                        break;

                }
            }
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1: 
                    UEKA01(dwData); 
                    break;
                default:
                    break;
            }  
            Connect2Proxy(or1);
        }
        public void UEKA01(DataRow dwData)
        {
            dwData["EKAAENB"] = app.Mandant;
            dwData["EKAAEND"] = date;
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "UPDATE EKADR SET EKAMANDANT=:EKAMANDANT:,EKAAUFKRS=:EKAAUFKRS:,EKAAUFLFD=:EKAAUFLFD:,EKAAUFPOS=:EKAAUFPOS:,EKABNAME1=:EKABNAME1:,EKABNAME2=:EKABNAME2:,EKABSTRASSE1=:EKABSTRASSE1:,EKABSTRASSE2=:EKABSTRASSE2:,EKABLKZ=:EKABLKZ:,EKABPLZ=:EKABPLZ:,EKABORT=:EKABORT:,EKABPLZPF=:EKABPLZPF:,EKABPOSTF=:EKABPOSTF:,EKABBZ=:EKABBZ:,EKABBZBEZ=:EKABBZBEZ:,EKABCOUNTY=:EKABCOUNTY:,EKABCITY=:EKABCITY:,EKABANSPNA=:EKABANSPNA:,EKALNAME1=:EKALNAME1:,EKALNAME2=:EKALNAME2:,EKALSTRASSE1=:EKALSTRASSE1:,VKALSTRASSE2=:VKALSTRASSE2:,EKALLKZ=:EKALLKZ:,EKALPLZ=:EKALPLZ:,EKALORT=:EKALORT:,EKALBZ=:EKALBZ:,EKALBZBEZ=:EKALBZBEZ:,EKALCOUNTY=:EKALCOUNTY:,EKALCITY=:EKALCITY:,EKAADRSL1=:EKAADRSL1:,EKALIEFNR1=:EKALIEFNR1:,EKAANZ1=:EKAANZ1:,EKAADRSLK11=:EKAADRSLK11:,EKALIEFNRK11=:EKALIEFNRK11:,EKAANZK11=:EKAANZK11:,EKAADRSLK21=:EKAADRSLK21:,EKALIEFNRK21=:EKALIEFNRK21:,EKAANZK21=:EKAANZK21:,EKAADRSL2=:EKAADRSL2:,EKALIEFNR2=:EKALIEFNR2:,EKAANZ2=:EKAANZ2:,EKAADRSLK12=:EKAADRSLK12:,EKALIEFNRK12=:EKALIEFNRK12:,EKAANZK12=:EKAANZK12:,EKAADRSLK22=:EKAADRSLK22:,EKALIEFNRK22=:EKALIEFNRK22:,EKAANZK22=:EKAANZK22:,EKAADRSL3=:EKAADRSL3:,EKALIEFNR3=:EKALIEFNR3:,EKAANZ3=:EKAANZ3:,EKAADRSLK13=:EKAADRSLK13:,EKALIEFNRK13=:EKALIEFNRK13:,EKAANZK13=:EKAANZK13:,EKAADRSLK23=:EKAADRSLK23:,EKALIEFNRK23=:EKALIEFNRK23:,EKAANZK23=:EKAANZK23:,EKAFREIBAD=:EKAFREIBAD:,EKAFREILAD=:EKAFREILAD:,EKAERLKZ=:EKAERLKZ:,EKAFILLER1=:EKAFILLER1:,EKAAENZL=:EKAAENZL:,EKAAENB=:EKAAENB:,EKAAEND=:EKAAEND:,EKANEUB=:EKANEUB:,EKANEUD=:EKANEUD:"
                 + " WHERE  EKAMANDANT=:EKAMANDANT: AND EKAAUFKRS=:EKAAUFKRS: AND EKAAUFLFD=:EKAAUFLFD: AND EKAAUFPOS=:EKAAUFPOS: "; 
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData); 
            Connect2Proxy(or1);
        }
    }
}
